@echo off
setlocal enabledelayedexpansion
chcp 65001 

set "MIN_FILE_SIZE=10485760"
set "log_file=large_directories.log"
type nul > "%log_file%"

echo 正在查找包含大于10MB文件的目录...
echo 结果将保存到 %log_file%
echo ==============================
echo 查找时间：%date% %time% >> "%log_file%"

:: 递归遍历目录（修复括号和循环逻辑）
for /d /r %%d in (*) do (
    set "has_large_file=0"
    
    :: 检查目录下的文件（排除子目录）
    for %%f in ("%%d\*") do (
        if not exist "%%f\" (  :: 确保是文件而非目录
            if %%~zf gtr !MIN_FILE_SIZE! (
                set "has_large_file=1"
            )
        )
    )
    
    :: 输出结果
    if !has_large_file! equ 1 (
        echo 目录：%%d
        echo 目录：%%d >> "%log_file%"
        
        @REM for %%f in ("%%d\*") do (
        @REM     if not exist "%%f\" if %%~zf gtr !MIN_FILE_SIZE! (
        @REM         echo  └─ 大文件：%%~nxf (%%~zf 字节)
        @REM         echo  └─ 大文件：%%~nxf (%%~zf 字节) >> "%log_file%"
        @REM     )
        @REM )
        @REM echo ------------------------------
        @REM echo ------------------------------ >> "%log_file%"
    )
)

echo 查找完成，结果已保存到 %log_file%